package ben.samplegame.rules;

import java.util.ArrayList;
import java.util.List;
import ben.samplegame.sprite.SampleBullet;
import ben.samplegame.sprite.SpaceBackground;
import game.engine.GameRule;
import game.sprite.Sprite;

public class OutOfBoundsRule implements GameRule {
    
    private ArrayList<Sprite> myGameSprites;
    private SpaceBackground myBackground;
    
    public OutOfBoundsRule(List<Sprite> gameSprites, SpaceBackground background){
        myGameSprites = new ArrayList<Sprite>( gameSprites);
        myBackground = background;
    }

    @Override
    public void checkRules () {
        for(int i = myGameSprites.size()-1; i>=0; i--){
            Sprite s = myGameSprites.get(i);
            if(s instanceof SampleBullet){
                if(!myBackground.inBounds(s)){
                    myGameSprites.remove(s);
                    System.out.println("removing");
                }
            }
        }
        
    }

}
